package com.iss.ssm0531.controller;

import com.iss.ssm0531.model.User;
import com.iss.ssm0531.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    @ResponseBody
    public List<User> findAll(){
       return  userService.findAll();
    }

    @RequestMapping("/login")
    @ResponseBody
    public Boolean login(User user){
        System.out.println("username:"+ user.getUsername());
        System.out.println("password:"+user.getPassword());
        return  true;
    }
    @RequestMapping(value = "/save")
    @ResponseBody
    public  Boolean save(User user){

         return userService.save(user);
    }
    @RequestMapping("/find")
    @ResponseBody
    public User getSingle(Integer userId){
        return  userService.getSingle(userId);
    }


}
